import { http } from "@/utils/http";
import { AxiosPromise } from "axios";

export function planListAll(visitDate?: string): AxiosPromise<any> {
  return http.request({
    url: "/wiki/plan/list",
    method: "get",
    params: { visitDate }
  });
}

export function getPlanByDate(date: string) {
  return http.request({
    url: "wiki/plan/getPlanByDate/" + date,
    method: "get"
  });
}

export function savePlan(data: any): AxiosPromise<any> {
  return http.request({
    url: "/wiki/plan",
    method: "post",
    data
  });
}

export function updatePlan(data: any): AxiosPromise<any> {
  return http.request({
    url: "/wiki/plan",
    method: "put",
    data
  });
}

// 获取同行人
export function getUserList(): AxiosPromise<any> {
  return http.request({
    url: "system/user/getUserList",
    method: "get"
  });
}

export function planDetail(id: string): AxiosPromise<any> {
  return http.request({
    url: "/wiki/plan/" + id,
    method: "get"
  });
}

export function joiningPeers(data: { id: string }) {
  return http.request({
    url: "/wiki/plan/joiningPeers",
    method: "put",
    data
  });
}

export function exitPeers(data: { id: string }) {
  return http.request({
    url: "/wiki/plan/exitPeers",
    method: "put",
    data
  });
}

export function getPlanListAll(date: string) {
  return http.request({
    url: "wiki/plan/listAll",
    method: "get",
    params: { date }
  });
}
